// pages/user/account/account.js
const common = require('../../../utils/util.js')
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        accountInfo: {}
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
        this.getAccountInfo()
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    getAccountInfo: function() {
        wx.showLoading({
            title: '加载中',
        })
        const that = this
        let data = {}
        common.post('Wallet/user_money', data).then(function(res) {
            wx.hideLoading()
            that.setData({
                accountInfo: res
            })
        }).catch(function(e) {})
    },

    goAccountRecord: function() {
        wx.navigateTo({
            url: '/pages/user/account/accountRecord/accountRecord'
        })
    },

    goWithdrawRecord: function() {
        wx.navigateTo({
            url: '/pages/user/account/withdrawRecord/withdrawRecord'
        })
    },

    goWithdraw: function() {
        let nowDay = new Date().getDay()
        if (nowDay != 2) {
            wx.showToast({
                title: '提现功能仅在每周二开放',
                icon: 'none',
                duration: 1000
            })
            return
        }
        wx.navigateTo({
            url: '/pages/user/account/withdraw/withdraw'
        })
    }
})